<?php
declare (strict_types=1);

namespace app\index\controller;

use addons\V2\admin\model\ProductCate;
use app\common\tool\Result;
use think\facade\View;
use think\Response;

use app\common\model\News as NewsModel;

class Classify extends Base
{

    public function index()
    {
        $cate = ProductCate::where(['status' => 1])->where('id','>',2)
            ->field("id,icon,title")->find();

        $cate_id = $this->request->get('cate_id', $cate['id']);

        View::assign([
            'cate'    => $cate,
            'cate_id' => $cate_id,
            'child'   => ProductCate::where(['status' => 1])->where('id','>',2)
                ->field("id,icon,title")->order('sort')->select()
        ]);
        return View::fetch();
    }


    public function getList(): Response
    {
        return Result::fastReturn(NewsModel::getPageList([], 'id,title,create_time', $this->getPage()));
    }

}

